package com.dwsoft.word;

import com.dwsoft.xml.XDocument;
import com.dwsoft.xml.XParagraph;
import org.springframework.stereotype.Component;
import word.api.interfaces.IElement;
import word.w2004.Document2004;
import word.w2004.elements.Paragraph;
import word.w2004.elements.ParagraphPiece;
import word.w2004.style.Font;
import word.w2004.style.ParagraphPieceStyle;
import word.w2004.style.ParagraphStyle;

import java.io.IOException;

/**
 * @author sqw
 * @version 1.0
 * @description TODO
 * @ClassName WTitle
 * @Date 2020/8/17
 * @since jdk1.8
 */
@Component("title")
public class WTitle  extends WElement<XDocument>{

    @Override
    public void instance(XDocument xmlNode, Document2004 document) throws NoSuchMethodException, IOException {
        ParagraphPieceStyle style= ParagraphPiece.with(xmlNode.getValue()).withStyle();
        ParagraphPiece title = style.bold().fontSize(xmlNode.getFontSize()).font(Font.SIMSUN).create();
        IElement paragraph = Paragraph.withPieces(title).withStyle().align(ParagraphStyle.Align.CENTER).create();
        document.addEle(paragraph);
    }
}
